package designpattern.factory.simplefactory;

//披萨工厂
public class PizzaFactory {
    private static final PizzaFactory PIZZA_FACTORY = new PizzaFactory();

    private PizzaFactory(){}

    public static PizzaFactory getInstance(){
        return PIZZA_FACTORY;
    }

    //根据输入的pizza类型来返回对应pizza
    public Pizza createPizza(String pizzaType){
        Pizza pizza = null;
        if("cheese".equals(pizzaType)){
            pizza = new CheesePizza();
            pizza.setName("cheese");
        }else if("greek".equals(pizzaType)){
            pizza = new GreekPizza();
            pizza.setName("greek");
        }
        return pizza;
    }
}
